/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ipo.mm.ejb.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author makcro
 */
@Entity
@Table(name = "USER")
@NamedQueries({
    @NamedQuery(name = "User.findAllD", query = "SELECT u FROM User u"),
    @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u  WHERE u.deleted = false"),
    @NamedQuery(name = "User.findByUsername", query = "SELECT u FROM User u WHERE u.username = :username AND u.deleted = false"),
    @NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password"),
    @NamedQuery(name = "User.findByFirstName", query = "SELECT u FROM User u WHERE u.firstName = :firstName"),
    @NamedQuery(name = "User.findByLastName", query = "SELECT u FROM User u WHERE u.lastName = :lastName"),
    @NamedQuery(name = "User.findByType", query = "SELECT u FROM User u WHERE u.type = :type"),
    @NamedQuery(name = "User.findByDeleted", query = "SELECT u FROM User u WHERE u.deleted = :deleted")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Username")
    private String username;
    @Basic(optional = false)
    @Column(name = "Password")
    private String password;
    @Column(name = "FirstName")
    private String firstName;
    @Column(name = "LastName")
    private String lastName;
    @Basic(optional = false)
    @Column(name = "Type")
    private int type;
    @Basic(optional = false)
    @Column(name = "Deleted")
    private boolean deleted;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Collection<InstitutionRegion> institutionRegionCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Collection<Meeting> meetingCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Collection<Representative> representativeCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Collection<Institution> institutionCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Collection<City> cityCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Collection<InstitutionFamily> institutionFamilyCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Collection<InstitutionType> institutionTypeCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private Collection<Log> logCollection;

   
    public User() {
    }

    public User(String username) {
        this.username = username;
    }

    public User(String username, String password, int type, boolean deleted) {
        this.username = username;
        this.password = password;
        this.type = type;
        this.deleted = deleted;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public Collection<InstitutionRegion> getInstitutionRegionCollection() {
        return institutionRegionCollection;
    }

    public void setInstitutionRegionCollection(Collection<InstitutionRegion> institutionRegionCollection) {
        this.institutionRegionCollection = institutionRegionCollection;
    }

    public Collection<Meeting> getMeetingCollection() {
        return meetingCollection;
    }

    public void setMeetingCollection(Collection<Meeting> meetingCollection) {
        this.meetingCollection = meetingCollection;
    }

    public Collection<Representative> getRepresentativeCollection() {
        return representativeCollection;
    }

    public void setRepresentativeCollection(Collection<Representative> representativeCollection) {
        this.representativeCollection = representativeCollection;
    }

    public Collection<Institution> getInstitutionCollection() {
        return institutionCollection;
    }

    public void setInstitutionCollection(Collection<Institution> institutionCollection) {
        this.institutionCollection = institutionCollection;
    }

    public Collection<City> getCityCollection() {
        return cityCollection;
    }

    public void setCityCollection(Collection<City> cityCollection) {
        this.cityCollection = cityCollection;
    }

    public Collection<InstitutionFamily> getInstitutionFamilyCollection() {
        return institutionFamilyCollection;
    }

    public void setInstitutionFamilyCollection(Collection<InstitutionFamily> institutionFamilyCollection) {
        this.institutionFamilyCollection = institutionFamilyCollection;
    }

    public Collection<InstitutionType> getInstitutionTypeCollection() {
        return institutionTypeCollection;
    }

    public void setInstitutionTypeCollection(Collection<InstitutionType> institutionTypeCollection) {
        this.institutionTypeCollection = institutionTypeCollection;
    }

    public void setLogCollection(Collection<Log> logCollection) {
        this.logCollection = logCollection;
    }

    public Collection<Log> getLogCollection() {
        return logCollection;
    }

    
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.ipo.mm.ejb.entities.User[username=" + username + "]";
    }

}
